
Namespace persistent

    Public Class MenuProcess

        Public Shared Function GetRoles(ByVal menuID As Integer) As DataTable
            Return persistent.myDBConn.myORATable("select case when rc.role_id is null then 0 else 1 end ISAUTHORIZED, r.* from  billintra.role r  left outer join billintra.menu_permissions rc on r.role_id=rc.role_id and menu_id = " & menuID & " order by des")
            'Return persistent.myDBConn.myORATable("select case when rc.role_id is null then 0 else 1 end ISAUTHORIZED ,r.* from  role r  left outer join role_cross rc on r.role_id=rc.role_id  and grup=" & group & " and main=" & main & " and sub=" & menusub & " order by des")
        End Function

        'Public Shared Function GetMenuName() As DataTable

        '    Dim SQL As String


        '    SQL = "select menu_id id, menu_title text, parent_menu_id, display_order from billintra.menu2 where enabled = 'Y' order by menu_title"


        '    Return persistent.myDBConn.myORATable(SQL)
        'End Function

        Public Shared Function DeleteRoles(ByVal menuID As Integer) As String

            Dim sql As String
            sql = "select count(*) from  billintra.menu_permissions where  menu_id = " & menuID
            Dim DeletedOnes As DataTable = myDBConn.myORATable(sql)
            If DeletedOnes.Rows.Count > 0 Then
                sql = "delete from billintra.menu_permissions where  menu_id = " & menuID
                Return myDBConn.ORAExecute(sql)
            Else
                Return ""
            End If


        End Function
        Public Shared Function InsertRoles(ByVal menuID As String, ByVal roleID As String) As String

            Dim sql As String

            sql = " insert into billintra.menu_permissions (menu_id, role_id) values (" & menuID & ", " & roleID & ")"

            Return myDBConn.ORAExecute(sql)


        End Function


    End Class
End Namespace